<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="apple-mobile-web-app-title" content="">
  <meta name="format-detection" content="telephone=no">
  <meta name="full-screen" content="yes">
  <meta name="x5-page-mode" content="app">
  <meta name="x5-fullscreen" content="true">
  <meta name="browsermode" content="application">
  <meta content="" name="keywords">
  <meta content="" name="description">
  <link rel="stylesheet" href="https://cdn.bootcss.com/weui/1.1.3/style/weui.min.css">
  <link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.1/css/jquery-weui.min.css">
  <link rel="stylesheet" href="./js/layer_mobile/need/layer.css">
  <link rel="stylesheet" href="./css/style.css">
  <link rel="stylesheet" href="./iconfont/iconfont.css">
  <title>我的二维码</title>
  <style>
  .content { text-align: center; }
  .content img { max-width: 200px; }
  </style>

  <body>
    <script type="text/html" id='wrap'>
    <!-- 不是代理 -->
    {{# if(d.code != 0) { }}
      <div class="weui-msg">
        <div class="weui-msg__icon-area"><i class="weui-icon-warn weui-icon_msg"></i></div>
        <div class="weui-msg__text-area">
          <h2 class="weui-msg__title">您还不是代理</h2>
          <p class="weui-msg__desc">你还不是平台代理，点击下面按钮去<b>申请成为代理</b>吧。</p>
        </div>
        <div class="weui-msg__opr-area">
          <p class="weui-btn-area">
            <a href="applyProxy.html" class="weui-btn weui-btn_primary">申请代理</a>
          </p>
        </div>
      </div>
    {{# } else if(d.code == 0) { }}
      <!-- 尚未处理 -->
      {{# if(d.data.status != 2) { }}
        <div class="weui-msg">
          <div class="weui-msg__icon-area"><i class="weui-icon-waiting weui-icon_msg"></i></div>
          <div class="weui-msg__text-area">
            <h2 class="weui-msg__title">您的申请尚未处理</h2>
            <p class="weui-msg__desc">点击下面按钮去<b>查看申请进度</b>吧。</p>
          </div>
          <div class="weui-msg__opr-area">
            <p class="weui-btn-area">
              <a href="proxySpeed.html" class="weui-btn weui-btn_primary">查看申请进度</a>
            </p>
          </div>
        </div>
      {{# } else if(d.data.status == 2) { }}
        <!-- 是代理 -->
        <div class="page__hd">
          <div class="page__title">我的二维码</div>
          <div class="page__desc">扫一扫，申请成为<span class="theme-color">商户</span></div>
        </div>
        
        <div class="content">
          {{# if(!d.data.qrcode) { }}
          <p class="gray-color"><b>尚未生成二维码</b></p>
          <p class="gray-color">请联系客服生成推广二维码</p>
          <a href="tel:13396767895">133 9676 7895</a>
          {{# } else { }}
          <img src="data:image/png;base64,{{d.data.qrcode}}" alt="">
          <p class="gray-color">长按保存二维码</p>
          {{# } }}
        </div>
      {{# } }}
    {{# } }}
    </script>
    <div id="render"></div>

    <div class="weui-msg__extra-area">
      <div class="weui-footer">
        <p class="weui-footer__text">Copyright © 天空文化传播</p>
      </div>
    </div>
  </body>

  <script src="https://cdn.bootcss.com/jquery/1.11.0/jquery.min.js"></script>
  <script src="https://cdn.bootcss.com/vConsole/3.3.0/vconsole.min.js"></script>
  <script src="./js/tools2.js?ver=2.1"></script>
  <script src="./js/jweixin-1.4.0.js?ver=1.0"></script>
  <script src="./js/layer_mobile/layer.js"></script>
  <script src="./js/layer_mobile/laytpl.js"></script>
  <script>
    // var vConsole = new VConsole();
    var mid = tools.getItem('userInfo').user_code;   // 用户id
    var gettep = $('#wrap').html();   // layui区域

    $(function() {
      tools.login(function() {
        getSpeed();
      })
    })

    // 获取申请进度
    function getSpeed() {
      tools.ajax({
        url: "/proxy/" + mid,
        success: function(res) {
          if(res.code == 0) {
            laytpl(gettep).render(res, function(html) {
              $('#render').html(html);
            })
          }
        }
      })
    }

    tools.hide();
  </script>
</body>
</html>